package com.xindaoapp.happypet.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.xindaoapp.happypet.R;
import com.xindaoapp.happypet.bean.Groups.Group;
import com.xindaoapp.happypet.view.CircleImageView;

public class HZTAdapter extends BaseAdapter {
    private final List<Group> list;
    private final Context mContext;


    public HZTAdapter(Context context) {
        this.mContext = context;
        this.list = new ArrayList<Group>();
    }

    public void addObject(List<Group> groups) {
        if (groups != null)
            list.addAll(groups);
        notifyDataSetChanged();
    }

    public List<Group> getList() {
        return list;
    }

    public void clearObject() {
        list.clear();
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = View.inflate(mContext, R.layout.item_banzhuicon, null);
        CircleImageView gv_banzhu_icon =
                (CircleImageView) convertView.findViewById(R.id.banzhu_icon);
        TextView gv_banzhu_name = (TextView) convertView.findViewById(R.id.banzhu_name);
        ImageLoader.getInstance().displayImage(list.get(position).ico, gv_banzhu_icon);
        gv_banzhu_name.setText(list.get(position).name);
        return convertView;
    }

}
